def decorator(func):
    def inner():
        func()
        print('this is from decorate')
    return inner
    # return inner


# @decorator
def hello():
    print('hello world')


# hello() #装饰器方式调用

h = decorator(func=hello)  # 函数句柄调用
h()


# Decorate func
def deter(type_to):
    print(type_to)

    def outter(func):
        def gf(*args, **kwargs):
            res = func(*args, **kwargs)
            print('gf args=', *args, **kwargs)
            print('decorate complete!')
            return res

        return gf

    return outter


@deter(type_to='android')
def figures(a, b, c):
    for i in range(1, 5):
        for j in range(1, 5):
            for k in range(1, 5):
                if k == j or k == i or i == j:
                    continue
                print(str(i) + str(j) + str(k))

    return ('count complete!')


print(figures(1, 4, 5))


# 如何使用装饰器函数


# 1. slample
def decorate(v):
    print('decorate =', v)

    def outter(func):
        def inner(a, b):
            func(a, b)
            print('inner func')

        return inner

    return outter


@decorate(v=2)
def add(a, b):
    print('add func=', a + b)


add(a=1, b=3)
